package global

import (
	"fmt"
	"github.com/spf13/viper"
)

type AppConfig struct {
	Mysql
}

type Mysql struct {
	User     string
	Password string
	Host     string
	Port     int
	Database string
}

func InitViper() {
	viper.SetConfigFile("../grpc/basic/appconfig/dev.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		return
	}
	err = viper.Unmarshal(&ConfigData)
	if err != nil {
		return
	} else {
		fmt.Println("动态读取成功", ConfigData)
	}
}
